

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class PlayerTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class PlayerTest
{
    private Room room1;
    private Player player1;
    private Item item1;
    private Item heavyItem;
    private Weapon weapon1;
    private Monster monster1;

    /**
     * Default constructor for test class PlayerTest
     */
    public PlayerTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
        room1 = new Room("playerTestRoom");
        player1 = new Player("the test player", 100, 200, 250, room1);
        item1 = new Item("lightItem", "this be one of them light items", 1, 10);
        heavyItem = new Item("heavyItem", "wow. ULTRA HEAVY!", 1000, 10);
        weapon1 = new Weapon("weak weapon", "does +0 damage", 10, 10);
        monster1 = new Monster("The dentist", 30, room1, 20, "blah", "blah");
        room1.setMonster(monster1);
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }

    @Test
    public void Heal()
    {
        assertEquals("you healed for 20 your new health is 220", player1.heal(20));
    }

    @Test
    public void HealTooMuch()
    {
        assertEquals("you healed for 200 your new health is 250", player1.heal(200));
    }

    @Test
    public void HealWithFullHealth()
    {
        player1.heal(200);
        assertEquals("your health is already full!", player1.heal(10));
    }

    @Test
    public void addItem()
    {
        assertEquals(true, player1.addToInventory(item1));
    }

    @Test
    public void addTooHeavyItem()
    {
        assertEquals(false, player1.addToInventory(heavyItem));
    }

    @Test
    public void getItemFromRoom()
    {
        room1.addItem(weapon1);
        assertEquals(true, player1.getItemFromRoom("weak weapon"));
        assertNull(room1.getItem("weak weapon"));
    }

    @Test
    public void checkInventoryWeight()
    {
        player1.addToInventory(item1);
        assertEquals(1, player1.getTotalInventoryWeight());
    }

    @Test
    public void testUnlocking()
    {
        Room lockedRoom = new Room("lockedRoom");
        room1.setExit("north", lockedRoom);
        room1.lockExit("north", "the key");
        Item key = new Item("the key", "blah", 10, 10);
        assertEquals(true, player1.addToInventory(key));
        assertEquals(true, player1.unlock("north", "the key"));
        assertNull(room1.isDoorLocked("north"));
    }

    @Test
    public void eatSomething()
    {
        Consumeable consumea1 = new Consumeable("cookie", "a cookie!", 1, 10);
        assertEquals(true, player1.addToInventory(consumea1));
        assertEquals("you healed for 10 your new health is 210", player1.eatItem("cookie"));
    }

    @Test
    public void attackWithLightWeapon()
    {
        assertEquals(true, player1.addToInventory(weapon1));
        assertEquals("combat.mp3", player1.attack());
    }

    @Test
    public void attackWithHeavyWeapon()
    {
        Weapon heavyWeapon = new Weapon("heavyWeapon", "does BOOM!", 10, 1000);
        assertEquals(true, player1.addToInventory(heavyWeapon));
        assertEquals("blah", player1.attack());
    }

    @Test
    public void attackWithoutWeapon()
    {
        assertEquals("", player1.attack());
    }

    @Test
    public void attackWithoutEnemy()
    {
        room1.monsterDefeated();
        player1.attack();
        assertEquals(true, player1.addToInventory(weapon1));
        assertEquals("", player1.attack());
    }
}













